import axios from '@/libs/api.request'

// 发送验证码
export const sendSms = (mobile) => {
  return axios.request({
    url: 'User/sendSms',
    data: { mobile },
    method: 'post',
    noToken: true
  })
}

// 注册
export const register = ({ mobile, password, name, channelSrc, code, leaderId}) => {
  const data = {
    mobile,
    password,
    name,
    channelSrc,
    code,
    leaderId
  }
  return axios.request({
    url: 'User/register',
    data,
    method: 'post',
    noToken: true
  })
}

// 登录
export const login = ({ mobile, password }) => {
  const data = {
    mobile, password
  }
  return axios.request({
    url: 'User/login',
    data,
    method: 'post',
    noToken: true
  })
}

// 登出
export const loginOut = () => {
  return axios.request({
    url: 'User/loginOut',
    method: 'post',
    noToken: true
  })
}

// 忘记密码
export const forgetPassword = ({ mobile, password, code }) => {
  const data = {
    mobile, password, code
  }
  return axios.request({
    url: 'User/forgetPassword',
    data,
    method: 'post',
    noToken: true
  })
}

// 修改姓名
export const editName = ({ cid, name }) => {
  const data = {
    cid, name
  }
  return axios.request({
    url: 'User/editName',
    data,
    method: 'post'
  })
}

// 修改密码
export const editPassword = ({ cid, password }) => {
  const data = {
    cid, password
  }
  return axios.request({
    url: 'User/editPassword',
    data,
    method: 'post'
  })
}

// 编辑银行卡信息
export const editBankCardInformation = ({ cid, bankCardUserName, bankCardNumber, bank }) => {
  const data = {
    cid, bankCardUserName, bankCardNumber, bank
  }
  return axios.request({
    url: 'User/editBankCardInformation',
    data,
    method: 'post'
  })
}

// 编辑渠道
export const editChannelSrc = ({ cid, channelSrc }) => {
  const data = {
    cid, channelSrc
  }
  return axios.request({
    url: 'User/editChannelSrc',
    data,
    method: 'post'
  })
}

// 获取我的团队
export const getTeam = (cid) => {
  return axios.request({
    url: 'User/getTeam',
    data: {cid},
    method: 'post'
  })
}

// 查询用户放款金额列表
export const getUserLoan = (cid) => {
  return axios.request({
    url: 'User/getUserLoan',
    data: {cid},
    method: 'post'
  })
}

// 查询贷款详情
export const getUserLoanDetail = (id) => {
  return axios.request({
    url: 'User/getUserLoanDetail',
    data: {id},
    method: 'post'
  })
}

// 获取佣金来源列表
export const getUserRewardList = (cid) => {
  return axios.request({
    url: 'User/getUserRewardList',
    data: {cid},
    method: 'post'
  })
}

// 获取用户详情
export const getUserDetail = (cid) => {
  return axios.request({
    url: 'User/getUserDetail',
    data: {cid},
    method: 'post'
  })
}

// 获取海报列表
export const getPosterList = () => {
  return axios.request({
    url: 'User/getPosterList',
    method: 'post'
  })
}

// 获取用户名片
export const getUserPosterList = (cid) => {
  return axios.request({
    url: 'User/getUserPosterList',
    data: {cid},
    method: 'post'
  })
}

// 获取用户名片
export const editPoster = ({id, cid, posterId, name, mobile, status}) => {
  const data ={
    id, cid, posterId, name, mobile, status
  }
  return axios.request({
    url: 'User/editPoster',
    data: data,
    method: 'post'
  })
}
